package com.zoagroup.funzy.entity;

import java.io.Serializable;

import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import com.zoagroup.funzy.entity.pk.UserMessagePK;


/**
 * The persistent class for the ranking_user database table.
 * 
 */
@Entity
@Table(name="user_message")
public class UserMessage implements Serializable{
	private static final long serialVersionUID = 1L;

	@EmbeddedId
	private UserMessagePK id;

	private int status;

	//bi-directional many-to-one association to Ranking
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="id_user", insertable=false, updatable=false)
	private User user;

	//bi-directional many-to-one association to User
	@ManyToOne(fetch=FetchType.EAGER)
	@JoinColumn(name="id_msg", insertable=false, updatable=false)
	private Message message;

	public UserMessagePK getId() {
		return id;
	}

	public void setId(UserMessagePK id) {
		this.id = id;
	}

	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public Message getMessage() {
		return message;
	}

	public void setMessage(Message message) {
		this.message = message;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		UserMessage other = (UserMessage) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		return true;
	}
}